package com.test.book.service;

import com.test.book.mapper.UserMapper;
import com.test.book.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    UserMapper userMapper;
    public String selectPasswordByName(String name){
        String password = userMapper.selectByName(name).getPassword();
        return password;
    }

    public Boolean isCorrectName(String name){
        List<String> names = userMapper.selectUserName();
        for (String name2:names) {
            if (name.equals(name2)) {
                return true;
            }
        }
        return false;
    }

    public UserInfo queryByCondition(String userName,String password){
        return userMapper.queryUserByCondition(userName,password);

    }
}
